<?php

namespace App\Services\Game;
use App\DTOS\Admin\MemberKeepDTO;
use App\Models\Game\MemberLtu;

class MemberLtuervice
{
    public function paginate(MemberKeepDTO $DTO)
    {
        //沿用留存的实体类，新增渠道字段
        $perPage = $DTO->getLimit();
        $page = $DTO->getPage();
        $gameArea = $DTO->getGameArea();
        $channel = $DTO->getChannel();
        $model = MemberLtu::query();
        $createDateBegin = $DTO->getCreateDateBegin();
        $createDateEnd = $DTO->getCreateDateEnd();
        if ($createDateBegin) {
            $model->where('ymd','>=',$createDateBegin);
        }
        if ($createDateEnd){
            $model->where('ymd','<=',$createDateEnd);
        }
        if ($gameArea!==null) {
            $model->where('game_area',$gameArea);
        }
        if ($channel!==null) {
            $model->where('channel',$channel);
        }
        return $model->orderByDesc('ymd')->paginate($perPage,'*','page',$page);
    }
}
